package io.renren.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.sys.entity.SysDeptRegEntity;
import io.renren.modules.sys.service.SysDeptRegService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 部门管理
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-12-06 23:01:51
 */
@RestController
@RequestMapping("/sys/sysdeptreg")
public class SysDeptRegController {
    @Autowired
    private SysDeptRegService sysDeptRegService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:sysdeptreg:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysDeptRegService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{deptId}")
    @RequiresPermissions("sys:sysdeptreg:info")
    public R info(@PathVariable("deptId") Long deptId){
			SysDeptRegEntity sysDeptReg = sysDeptRegService.selectById(deptId);

        return R.ok().put("sysDeptReg", sysDeptReg);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:sysdeptreg:save")
    public R save(@RequestBody SysDeptRegEntity sysDeptReg){
			sysDeptRegService.insert(sysDeptReg);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:sysdeptreg:update")
    public R update(@RequestBody SysDeptRegEntity sysDeptReg){
			sysDeptRegService.updateById(sysDeptReg);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:sysdeptreg:delete")
    public R delete(@RequestBody Long[] deptIds){
			sysDeptRegService.deleteBatchIds(Arrays.asList(deptIds));

        return R.ok();
    }

}
